using System.Linq;
using UnityEngine;
using UnityEngine.Networking;

public class Explosion : DamageBase
{
	public bool IgnoreTeam;

	public float Duration = 3f;

	public float Force = 100f;

	public float Radius = 30f;

	public byte Damage = 100;

	public string[] BlockerTag = new string[1]
	{
		"Scene"
	};

	private void Start()
	{
		Collider[] array = Physics.OverlapSphere(base.transform.position, Radius);
		Collider[] array2 = array;
		DamagePackage damagePackage = default(DamagePackage);
		foreach (Collider collider in array2)
		{
			float num = Vector3.Distance(base.transform.position, collider.transform.position);
			float num2 = 1f - 1f / Radius * num;
			if (num2 < 0f)
			{
				num2 = 0f;
			}
			RaycastHit[] array3 = (from h in Physics.RaycastAll(base.transform.position, (collider.transform.position - base.transform.position).normalized, num + 0.2f)
				orderby h.distance
				select h).ToArray();
			for (int j = 0; j < array3.Length; j++)
			{
				RaycastHit raycastHit = array3[j];
				if ((bool)raycastHit.collider.GetComponent<Rigidbody>())
				{
					raycastHit.collider.GetComponent<Rigidbody>().AddExplosionForce(Force, base.transform.position, Radius, 3f);
				}
				damagePackage.Damage = Damage;
				damagePackage.Normal = raycastHit.normal;
				damagePackage.Direction = (collider.transform.position - base.transform.position).normalized * Force;
				damagePackage.Position = raycastHit.point;
				damagePackage.ID = OwnerID;
				damagePackage.DamageType = 0;
				if (IgnoreTeam)
				{
					damagePackage.Team = OwnerTeam;
				}
				else
				{
					damagePackage.Team = 0;
				}
				raycastHit.collider.GetComponent<Collider>().SendMessage("OnHit", damagePackage, SendMessageOptions.DontRequireReceiver);
			}
		}
		UnityEngine.Object.Destroy(base.gameObject, Duration);
	}

	private bool tagDestroyerCheck(string tag)
	{
		for (int i = 0; i < BlockerTag.Length; i++)
		{
			if (BlockerTag[i] == tag)
			{
				return true;
			}
		}
		return false;
	}

	private void UNetVersion()
	{
	}

	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		bool flag = base.OnSerialize(writer, forceAll);
		bool flag2 = default(bool);
		return flag2 | flag;
	}

	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		base.OnDeserialize(reader, initialState);
	}
}
